#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <istream>
#include <map>
#include <vector>
using ll = int64_t;

ll n,ans=0;
std::vector<ll> a,raw;
std::map<ll, ll> m;
std::vector<ll> t;



static inline constexpr ll lb(ll n){
    return n&(-n);
}

static inline void upd(ll idx, ll add){
    while(idx<=n){
        t[idx]+=add;
        idx+=lb(idx);
    }
}

static inline ll get(ll idx){
    ll res=0;
    while(idx){
        res+=t[idx];
        idx-=lb(idx);
    }
    return res;
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>n;
    raw.resize(n+1);
    t.resize(n+1);
    for(ll i=1;i<=n;++i){
        std::cin>>raw[i];
    }
    a=raw;
    std::sort(a.begin()+1,a.end());
    for(ll i=1;i<=n;i++){
        m[a[i]]=i;
    }
    for(ll i=1;i<=n;i++){
        raw[i]=m[raw[i]];
        // printf("raw[%lld]=%lld\n",i,raw[i]);
    }
    for(ll i=1;i<=n;i++){
        ll g=n-raw[i];
        ll l=i-1-get(raw[i]);
        ll r = g-l;
        // printf("i=%lld, l=%lld, r=%lld\n",i,l,r);
        if(std::max(l,r)>std::min(l,r)*2){
            ans++;
        }
        upd(raw[i],1);
    }
    std::cout<<ans<<"\n";
}